/*
 * @Author: Simon 1958058172@qq.com
 * @Date: 2025-08-08 10:28:15
 * @LastEditors: Simon 1958058172@qq.com
 * @LastEditTime: 2025-08-08 11:16:12
 * @FilePath: \java.1212\csdn\baozhuang\li06\work01.java
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package csdn.baozhuang.li06;

import java.util.Scanner;

public class work01 {
    public static void main(String[] args) {
        System.out.println("请输入一段字符");
        Scanner scanner=new Scanner(System.in);
        String s=scanner.nextLine();
        int l=s.length();
        System.out.println("字符串长度:"+l);
        if(l>3){ System.out.println("索引为2的字符"+s.charAt(2));}
        else System.out.println("索引为2的字符不存在");
        char[] ch=s.toCharArray();
        int count=0;
        for(char ch1:ch){
            if(Character.isDigit(ch1)){count++;}
        }
        System.out.println("字符串中为数字的个数是："+count);
    }
}
